//
//  BaseController.swift
//  WeiBo
//
//  Created by 江潘 on 15/6/24.
//  Copyright © 2015年 江潘. All rights reserved.
//

import UIKit

class BaseController:UITableViewController,VisitViewDelegate{

    var visitV:VisitView?
    
    var loginFlag = sharedAccount != nil
    
    override func loadView() {
        
        loginFlag ? super.loadView() : setupVisitView()
    }
    
  private func setupVisitView(){
        
        visitV = VisitView()
    
        visitV?.delegate = self
    
         view = visitV!
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitViewClickRegisterBtn")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitViewClickLoginBtn")
    }
    
    func visitViewClickLoginBtn() {
        
        let nav = UINavigationController(rootViewController: OAuthViewController())
        
        presentViewController(nav, animated:true, completion: nil)
        
        print("登录")
    }
    
    func visitViewClickRegisterBtn() {
        
        print("注册")
    }
}
  